unit TemeljnicaRpt;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DBBaseRpt, DokumentRpt, EXLReportExcelTLB, EXLReportBand, EXLReport, DB,
  DBClient, alBaseDataSet, MConnect;

type
  TrptTemeljnica = class(TrptDokument)
    procedure OnSetCellValue(Sender: TObject; Band: TEXLReportBand;
      RowInTemplate, RowInReport, ColumnInReport: Integer;
      var CellValue: OleVariant);
  private
    { Private declarations }
  protected
    function GetSessionParamRelations(DataSet: TDataSet): TSessionParamRelations; override;
    procedure Initialize; override;
  public
    { Public declarations }
  end;

var
  rptTemeljnica: TrptTemeljnica;

implementation

{$R *.dfm}

{ TrptTemeljnica }

function TrptTemeljnica.GetSessionParamRelations(
  DataSet: TDataSet): TSessionParamRelations;
begin
  if DataSet = cdsMain then
  begin
    SetLength(Result, 1);
    Result[0].FieldName := 'REF_ID';
    Result[0].SessionName := 'POSLOVNO_LETO_ID';
  end;
end;

procedure TrptTemeljnica.Initialize;
var
  TitleBand: TExlReportBand;
  MasterHeaderBand: TExlReportGroupHeaderBand;
  MasterDataBand: TExlReportBand;
  MasterFooterBand: TExlReportGroupFooterBand;
begin
  inherited;
  TitleBand := rptMain.Bands.AddBand(xlrbtTitle);
  TitleBand.Range := 'A1:G2';
  MasterHeaderBand := TExlReportGroupHeaderBand(rptMain.Bands.AddBand(xlrbtGroupHeader));
  MasterHeaderBand.Range := 'A3:G5';
  MasterHeaderBand.FieldName := 'STEVILKA';
  MasterDataBand := rptMain.Bands.AddBand(xlrbtMasterData);
  MasterDataBand.Range := 'A6:G6';
  MasterFooterBand := TExlReportGroupFooterBand(rptMain.Bands.AddBand(xlrbtGroupFooter));
  MasterFooterBand.Range := 'A7:G8';
  MasterHeaderBand.Footer := MasterFooterBand;
end;

procedure TrptTemeljnica.OnSetCellValue(Sender: TObject; Band: TEXLReportBand;
  RowInTemplate, RowInReport, ColumnInReport: Integer;
  var CellValue: OleVariant);
begin
  inherited;
  if (Band.BandType = xlrbtMasterData) and (ColumnInReport = 5) then
  begin
    if cdsMain.FieldByName('STEVILKA').AsInteger = CellValue then
      CellValue := '';
  end;
end;

initialization
  RegisterClass(TrptTemeljnica);

end.
